package org.example.graphql;

import cn.hutool.core.io.FileUtil;
//import graphql.ExecutionResult;
//import graphql.GraphQL;
//import graphql.schema.GraphQLSchema;
//import graphql.schema.StaticDataFetcher;
//import graphql.schema.idl.RuntimeWiring;
//import graphql.schema.idl.SchemaGenerator;
//import graphql.schema.idl.SchemaParser;
//import graphql.schema.idl.TypeDefinitionRegistry;

public class HelloWorld {
//    public static void main(String[] args) {
//        String schema = "type Query{hello: String, version: String} schema{query: Query}";
//        SchemaParser schemaParser = new SchemaParser();
//        TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(FileUtil.file("graphql/schema/HelloWorld.graphqls"));
//        RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
//                .type("Query", builder ->
//                        builder.dataFetcher("hello", new StaticDataFetcher("world"))
//                                .dataFetcher("version", new StaticDataFetcher("1"))
//                )
//                .build();
//        SchemaGenerator schemaGenerator = new SchemaGenerator();
//        GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
//        GraphQL build = GraphQL.newGraphQL(graphQLSchema).build();
//        ExecutionResult executionResult = build.execute(FileUtil.readUtf8String(FileUtil.file("graphql/query/HelloWorld.graphqls")));
//        System.out.println(executionResult.getData().toString());
//    }
}
